
<template>
  <div class="cionfirm-box fill" :class="{active:appear}">
    <div class="window hvc">
        <p class="ttl">{{confirmInfo.title}}</p>
        <p class="text">{{confirmInfo.text}}</p>
        <div class="btns flex flex-justify-content">
          <p class="cancel fillBf" @click="confirm(false)">{{confirmInfo.cancelText}}</p>
          <p class="base-btn" @click="confirm(true)">{{confirmInfo.confirmText}}</p>
        </div>
        <p class="close cursor" @click="confirm(false)">×</p>
    </div>
  </div>
</template>

<script>
  
  module.exports = {
    data: function () {
      return {
        appear:false,
        confirmInfo:{
          title:'确定删除?',
          text:'点击“删除”钮会将已选取的视频清掉',
          cancelText:'取消',
          confirmText:'删除',
        },
        resolveCallback: null, // 用于存储 Promise 的 resolve 回调
      }
    },
    methods:{
      hdlShow(obj){
        this.confirmInfo = obj;
        this.appear = true;
        let This = this;
        return new Promise((resolve) => {
          This.resolveCallback = resolve;
        });
      },
      confirm(val){
        this.appear = false;
        if (this.resolveCallback) {
          console.log(val);
          this.resolveCallback(val); // 返回用户的选择结果
          this.resolveCallback = null;
        }
      },
    },
    created: function () {
      // this.getCode();
      
    }
  }
</script>
<style>
  .cionfirm-box{
    position: fixed;
    z-index: 40;
    background: rgba(0, 0, 0, .5);
    display: none;
  }
  .cionfirm-box.active{
    display: block;
  }
  .cionfirm-box .window{
    width: 320px;
    box-sizing: content-box;
    background: rgb(32, 35, 41);
    box-shadow: rgba(0, 0, 0, 0.2) 0px 3px 10px 0px;
    border-radius: 4px;
    padding: 48px 40px 40px;
    text-align: center;
    color: #fff;
  }
  .cionfirm-box .window .ttl{
    font-size: 18px;
    opacity: 0.87;
    line-height: 26px;
  }
  .cionfirm-box .window .text{
    font-size: 14px;
    opacity: 0.6;
    line-height: 20px;
    margin: 16px 0 24px;
  }
  .cionfirm-box .window .btns p{
    font-size: 16px;
    width: 150px;
    line-height: 44px;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
  }
  .cionfirm-box .window .btns p:last-child{
    color: #000;
  }
  .cionfirm-box .window .btns p + p{
    margin-left: 20px;
  }
  .cionfirm-box .window .close{
    position: absolute;
    right: 6px;
    top: 6px;
    padding: 10px;
    color: rgba(255, 255, 255, .6);
  }
  
  
</style>
